package cn.edu.wfit.modules.learn.controller.coursemanagement;

import java.util.List;

import cn.edu.wfit.modules.learn.domain.WfitStuCase;
import cn.edu.wfit.modules.learn.service.coursemangement.IWfitStuCaseService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.edu.wfit.common.log.annotation.Log;
import cn.edu.wfit.common.log.enums.BusinessType;
import cn.edu.wfit.common.security.annotation.RequiresPermissions;

import cn.edu.wfit.common.core.web.controller.BaseController;
import cn.edu.wfit.common.core.web.domain.AjaxResult;
import cn.edu.wfit.common.core.utils.poi.ExcelUtil;
import cn.edu.wfit.common.core.web.page.TableDataInfo;

/**
 * 学生任务记录Controller
 * 
 * @author ruoyi
 * @date 2025-07-18
 */
@RestController
@RequestMapping("/submit")
public class WfitStuCaseController extends BaseController
{
    @Autowired
    private IWfitStuCaseService wfitStuCaseService;

    /**
     * 查询学生任务记录列表
     */
    @RequiresPermissions("system:case:list")
    @GetMapping("/list")
    public TableDataInfo list(WfitStuCase wfitStuCase)
    {
        startPage();
        List<WfitStuCase> list = wfitStuCaseService.selectWfitStuCaseList(wfitStuCase);
        return getDataTable(list);
    }

    /**
     * 导出学生任务记录列表
     */
    @RequiresPermissions("system:case:export")
    @Log(title = "学生任务记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WfitStuCase wfitStuCase)
    {
        List<WfitStuCase> list = wfitStuCaseService.selectWfitStuCaseList(wfitStuCase);
        ExcelUtil<WfitStuCase> util = new ExcelUtil<WfitStuCase>(WfitStuCase.class);
        util.exportExcel(response, list, "学生任务记录数据");
    }

    /**
     * 获取学生任务记录详细信息
     */
    @RequiresPermissions("system:case:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wfitStuCaseService.selectWfitStuCaseById(id));
    }

    /**
     * 新增学生任务记录
     */
    @RequiresPermissions("system:case:add")
    @Log(title = "学生任务记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WfitStuCase wfitStuCase)
    {
        return toAjax(wfitStuCaseService.insertWfitStuCase(wfitStuCase));
    }

    /**
     * 修改学生任务记录
     */
    @RequiresPermissions("system:case:edit")
    @Log(title = "学生任务记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WfitStuCase wfitStuCase)
    {
        return toAjax(wfitStuCaseService.updateWfitStuCase(wfitStuCase));
    }

    /**
     * 删除学生任务记录
     */
    @RequiresPermissions("system:case:remove")
    @Log(title = "学生任务记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wfitStuCaseService.deleteWfitStuCaseByIds(ids));
    }
}
